﻿using CefSharp;
using System;
using System.Collections.Generic;
using System.Text;

namespace WebBrowserTest
{
    public class DownloadHandler : IDownloadHandler
    {
        public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
        {
            if (!callback.IsDisposed)
            {
                using (callback)
                {
                    string path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, downloadItem.SuggestedFileName);
                    callback.Continue(path, true);
                }
            }

        }

        public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
        {

        }
    }

}
